<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript">
$(function() {
	var mtree = $("#moduleTree"),mtreeInit = false;
	var check = function(node, checked) {
		 if (node.target.disabled) {
			 return false;
		} 
	};
	var fn = function(mtree, n) {
		var find = mtree.tree("find",n.id);
		find.target.disabled = true;
		$.each(n.children || [], function(i, node) {
			fn(mtree, node);
		});
	};
	var disable = function(mtree, data) {
		$.each(data, function(i, n){
			fn(mtree, n);
		}); 
	};
	$("#detail-container").tabs({
		border : false,
		onSelect : function(title) {
			if (title == "操作权限" && !mtreeInit) {
				mtree.html("加载中，请稍候...");
				mtree.tree({
					checkbox : true,
					url : "${ctx}/userInfoController.do?method=getModuleTree&flag=operate&userid=${userid}",
					onLoadSuccess : function(node, data) {
						if (data && data.length > 0) {
							disable(mtree, data);
						}
					},
					onCheck : check,
					animate : true
				});
				mtreeInit = true;
			}
		}
	});
});
</script>
</head>
<body>
	<div id="detail-container">
		<div title="所属角色">
			<table class="data-grid" width="100%">
				<c:forEach items="${roles}" var="role">
					<tr>
						<td>${role.roleName}</td>
					</tr>
				</c:forEach>
			</table>
		</div>
		<div title="操作权限">
			<ul id="moduleTree"></ul>
		</div>
	</div>
</body>
</html>